package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ContaxxTexture;
import com.ruoyi.system.service.IContaxxTextureService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 质感系列Controller
 *
 * @author Yanghc
 * @date 2024-09-02
 */
@Controller
@RequestMapping("/system/texture")
public class ContaxxTextureController extends BaseController
{
    private String prefix = "system/texture";

    @Autowired
    private IContaxxTextureService contaxxTextureService;

    @RequiresPermissions("system:texture:view")
    @GetMapping()
    public String texture()
    {
        return prefix + "/texture";
    }

    /**
     * 查询质感系列列表
     */
    @RequiresPermissions("system:texture:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ContaxxTexture contaxxTexture)
    {
        startPage();
        List<ContaxxTexture> list = contaxxTextureService.selectContaxxTextureList(contaxxTexture);
        return getDataTable(list);
    }

    /**
     * 导出质感系列列表
     */
    @RequiresPermissions("system:texture:export")
    @Log(title = "质感系列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ContaxxTexture contaxxTexture)
    {
        List<ContaxxTexture> list = contaxxTextureService.selectContaxxTextureList(contaxxTexture);
        ExcelUtil<ContaxxTexture> util = new ExcelUtil<ContaxxTexture>(ContaxxTexture.class);
        return util.exportExcel(list, "质感系列数据");
    }

    /**
     * 新增质感系列
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存质感系列
     */
    @RequiresPermissions("system:texture:add")
    @Log(title = "质感系列", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ContaxxTexture contaxxTexture)
    {
        return toAjax(contaxxTextureService.insertContaxxTexture(contaxxTexture));
    }

    /**
     * 修改质感系列
     */
    @RequiresPermissions("system:texture:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ContaxxTexture contaxxTexture = contaxxTextureService.selectContaxxTextureById(id);
        mmap.put("contaxxTexture", contaxxTexture);
        return prefix + "/edit";
    }

    /**
     * 修改保存质感系列
     */
    @RequiresPermissions("system:texture:edit")
    @Log(title = "质感系列", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ContaxxTexture contaxxTexture)
    {
        return toAjax(contaxxTextureService.updateContaxxTexture(contaxxTexture));
    }

    /**
     * 删除质感系列
     */
    @RequiresPermissions("system:texture:remove")
    @Log(title = "质感系列", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(contaxxTextureService.deleteContaxxTextureByIds(ids));
    }
}
